import Creator from "../../../../ez/from/creator/form";
import com from "../../../../assets/js/com";
import model from "./model";

export default {
    searchBoxData: {},
    editBoxData: {},
    searchBox() {
        let fb = Creator().setLabelWidth(60).setLabelPosition('right')
        fb.addText('name').setSpan(23).setPlaceholder("名称").setLabel('姓名')
        // return fb.getConfig()
        return false
    },
    editBox() {
        let fb = Creator().setLabelWidth(60).setLabelPosition('right')
        fb.addText('name').setSpan(23).setPlaceholder("名称").setLabel('姓名')
        // fb.addText('age').setSpan(23).setPlaceholder("名称").setLabel('姓名')
        // fb.addRadio('sex').setSpan(23).setPlaceholder('性別').setLabel('性別')
        //     .addChoiceText("男").addChoiceText("女")
        // return fb.getConfig()
        return false
    },
    list() {
        let _this = this
        let page = 1
        let limit = 10
        let total = 10
        // let where = this.searchBoxData
        let order = ["-id"]
        let search = ""//暂未实现
        let depth = 3
        let group = 'app'

        let getList = function (cb) {
            console.log(page)
            let param = {
                _where: {
                    // parent__isnull:true
                },
                _order: order,
                _search: search,
                // _g: group,
                _d: depth,
                page,
                limit,
            }
            model.findBy(param, cb)
        }
        let getPage = function (p) {
            page = p
            getList()
        }
        let setPage = function (p) {
            page = p
        }
        let setPageSize = function (s) {
            limit = s
        }
        let init = function () {
            page = 1
            limit = 10
            total = 10
            _this.searchBoxData = {}
            order = ["-id"]
            search = {}//暂未实现
            depth = 3
            group = 'app'
        }

        return {
            page, limit, order, search, depth, group, total,
            init, getList, getPage, setPage, setPageSize
        }
    },
    listConfig() {
        let start = [{
            type: 'selection',
            width: 60,
            align: 'center',
            // fixed:'left'
        }, {
            title: "#",
            key: "id",
            width: 90
        }]
        let content = [__LIST_ITEMS__]
        let end = [{
            title: "操作",
            slot: "action",
            align: 'center',
            width: 150
        }]
        return start.concat(content, end)
    },
    action() {
        const remove = function (ids, cb) {
            com.showConfirm('确定删除？', () => {
                console.log(ids)
                model.remove(ids, cb)
            }, () => {
            })
        }
        const copy = function (ids, cb) {
            model.copy(ids, cb)
        }
        return {remove, copy}
    },
}
